﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall;
using FlatRedBall.Math.Geometry;
using FlatRedBall.Input;

namespace Emptiness
{
    public class Space : PositionedObject
    {
         #region Fields

        private Sprite mVisibleRepresentation;
        private Polygon mCollision;
        private int mass = 5;

        #endregion

        #region Properties

        public int Mass
        {
            get { return mass; }
            set { mass = value; }
        }


        #region XML Docs
        /// <summary>
        /// The collision of the object - can be used to perform collisions between entities.
        /// </summary>
        #endregion
        public Polygon Collision
        {
            get { return mCollision; }
        }

        #endregion

        #region Methods

        #region XML Docs
        /// <summary>
        /// Creates the Entitity and adds it to the SpriteManager.  Also adds
        /// its components to their respective managers.
        /// </summary>
        /// <remarks>
        /// Be sure to call Destroy when done with this object so it cleans itself up.
        /// </remarks>
        /// <param name="contentManagerName">The content manager name to use for loading data.</param>
        #endregion
        public Space(string contentManagerName)
        {
            SpriteManager.AddPositionedObject(this);
            
            mVisibleRepresentation = SpriteManager.AddSprite("Assets/redball.bmp", contentManagerName);
            mVisibleRepresentation.AttachTo(this, false);
            Z = 0;

            mCollision = Polygon.CreateEquilateral(
                 8, // Number of sides
                 1, // Radius
                 0);// Angle of first point in radians
            mCollision.AttachTo(this, false); // Don't forget to attach to this
            // Add the collision to the ShapeManager if you
            // want it to be visible.  This can help with debugging.
            bool collisionVisible = false;
            if (collisionVisible)
            {
                ShapeManager.AddPolygon(mCollision);
            }

        }

        #region XML Docs
        /// <summary>
        /// Removes this and all of its components from their respective managers.
        /// </summary>
        #endregion
        public void Destroy()
        {
            SpriteManager.RemovePositionedObject(this);
            SpriteManager.RemoveSprite(mVisibleRepresentation);
            ShapeManager.Remove(mCollision);
        }

        #endregion


        public void Activity()
        {
            InputManager.Keyboard.ControlPositionedObject(this);
        }

    }
}
